const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
const webpack = require('webpack')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
module.exports = {
  mode: 'development',
  entry: {
    index1: path.join(__dirname, 'src/js/index1.js'),
    index2: path.join(__dirname, 'src/js/index2.js')
  },
  output: {
    path: path.join(__dirname, 'dist'),
    filename: '[name].[contenthash:8].js'
  },
  devServer:{
    port:3456,
    contentBase: path.join(__dirname, 'dist'),
    open:true,
  },
  module:{
    rules: [
      {
        test: /\.?js$/i,
        exclude: [{
          and: [/node_modules[\\/]/],
          not: [
            /debug[\\/]/,
          ]
        }],
        use: {
            loader: 'babel-loader',
            options: {    
                presets: ['@babel/preset-env'],  
                plugins: [] 
            }
        }
        ,
      },
      {
        test: /\.css$/i,
        use: ['style-loader','css-loader']
      }
    ]
  },
  plugins: [
    new CleanWebpackPlugin(),
    new HtmlWebpackPlugin({
    template:path.join(__dirname,'src/html/index.html'),
    filename:'index.html', 
    }),
  ]
}